package com.water.controller;


import com.water.service.TeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author wsj
 * @version 1.0
 * @description: TODO
 * @date 2022/1/13 23:07
 */
@Controller
/*url拼接*/
@RequestMapping("/team")
public class MyController {
    @Autowired
    private TeamService teamService;

    @RequestMapping("/hello.do")
    public ModelAndView add(){
        //HandlerMapping
        System.out.println("========controller---add======");
        teamService.add();
        ModelAndView mv = new ModelAndView();
        //相当于request.setAttrubite("湖人",12)
        mv.addObject("team","h湖人111111");
        //相当于request.Dispatcher("index").forward()
        mv.setViewName("index");
        return mv;
    }

    @RequestMapping(value = "/update.do",method = RequestMethod.POST)
    public ModelAndView update(){
        //HandlerMapping
        System.out.println("========controller---update======");
        teamService.add();
        ModelAndView mv = new ModelAndView();
        //相当于request.setAttrubite("湖人",12)
        mv.addObject("team","h湖人111111");
        //相当于request.Dispatcher("index").forward()
        mv.setViewName("update");
        return mv;
    }

}
